<template>
  <div>
    {{ $route.params.id }}
    <div class="topimg">
      <img
        :src="this.$route.query.img"
        alt
      />
      <div class="smallimg">
        <img
          :src="this.$route.query.smallimg"
          alt
        />
      </div>
      <div class="return">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">
            <van-icon name="arrow-left" color="red" size="20px" />
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </div>
    <div class="text">
      <h1>{{ this.$route.query.name }}</h1>
      <p>
        <span>评价4.9</span>
        <span>月售540单</span>
        <span>蓝骑士专送约30分钟</span>
      </p>
      <h3>
        <span>30减12</span>
        <span>配送费优惠</span>
        <b>3个优惠</b>
      </h3>
      <p>公告：尊敬的顾客您好，本店去冰产品仍有少量冰渣 谢谢</p>
    </div>
    <div class="tabs">
      <van-tabs color="rgb(35, 149, 255)" line-width="30px"> 
        <van-tab title="点餐">
          <h5>商家推荐</h5>
          <div class="swiper">
            <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
              <van-swipe-item>
                <img
                  :src="this.$route.query.swiperimg1"
                  alt
                />
                <img
                  :src="this.$route.query.swiperimg2"
                  alt
                />
                <img
                  :src="this.$route.query.swiperimg3"
                  alt
                />
              </van-swipe-item>
              <van-swipe-item>
                <img
                  :src="this.$route.query.swiperimg3"
                  alt
                />
                <img
                  :src="this.$route.query.swiperimg2"
                  alt
                />
                <img
                  :src="this.$route.query.swiperimg1"
                  alt
                />
              </van-swipe-item>
            </van-swipe>
          </div>
        </van-tab>
        <van-tab title="评价">
          123
        </van-tab>
        <van-tab title="商家"></van-tab>
      </van-tabs>
    </div>
    <div class="side">
      <van-sidebar v-model="activeKey">
        <van-sidebar-item title="热销" dot />
        <van-sidebar-item title="优惠" badge="5" />
        <van-sidebar-item title="扬之物" badge="99+" />
        <van-sidebar-item title="龙井上新" dot />
        <van-sidebar-item title="果味茶系列" badge="5" />
        <van-sidebar-item title="珍珠奶茶" badge="99+" />
        <van-sidebar-item title="香梅系列" dot />
        <van-sidebar-item title="奶茶味" badge="5" />
        <van-sidebar-item title="冬瓜系列" badge="99+" />
        <van-sidebar-item title="醇品裸茶" dot />
      </van-sidebar>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'  
export default {
  data() {
    return {
      activeKey: 0,
    };
  },
  computed: {
    ...mapState(['shop']) 
  },
  async mounted() {
    let url = "http://localhost:8080/data/shop.json";
    let res = await this.$axios.get(url);
    this.$store.dispatch("shop", res.data);
    console.log(this.$route.query)
  },
  created() {
    this.$store.dispatch('setshow',false)
  },
  beforeDestroy() {
    // this.$bus.$emit('footernav',true)
  },
};
</script>

<style lang="less" scoped>
.topimg {
  width: 100%;
  height: 125px;
  position: relative;
  img {
    width: 100%;
    height: 100%;
  }
  .smallimg {
    width: 75px;
    height: 75px;
    position: absolute;
    top: 50%;
    left: 40%;
    border: 1px solid #f5f5f5;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .return {
      position: absolute;
      top: 5px;
      left:5px;
  }
}
.text {
  text-align: center;
  margin-top: 30px;
  h1 {
    width: 230px;
    height: 25px;
    overflow: hidden;
    font-size: 20px;
    font-weight: 700;
    margin-left: 70px;
    text-overflow: ellipsis;
  }
  p {
    text-align: center;
    font-size: 11px;
    margin-top: 5px;
    color: #666;
    span {
      margin-right: 5px;
    }
  }
  h3 {
    font-weight: normal;
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 5px;
    span {
      border: 1px solid #f5f5f5;
      color: rgb(255, 75, 51);
      margin-right: 10px;
    }
    b {
      margin-left: 80px;
      font-weight: normal;
    }
  }
}
h5 {
  padding-left: 4.266667vw;
  color: #333;
  font-size: 0.3rem;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 0.266667rem;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #fff;
}
.swiper {
  img {
    width: 120px;
    height: 120px;
  }
}
h2 {
    text-align: center;
    font-size: 30px;
    color: chartreuse;
}
</style>